/*
 * Vector2D.h
 *
 *  Created on: 22 Oct 2012
 *      Author: Guy
 */

#ifndef VECTOR2D_H_
#define VECTOR2D_H_

namespace SolidityEngine {

class Vector2D {
	float _x;
	float _y;
public:
	Vector2D();
	Vector2D(float x,float y);
    ~Vector2D();

	float& X();
	float X() const;

	float& Y();
	float Y() const;

	Vector2D operator+(const Vector2D& rhs) const;
	Vector2D operator-(const Vector2D& rhs) const;
	Vector2D operator*(float rhs) const;

	float Length() const;

	Vector2D Normalized() const;

	void Normalize();

	void Set(float x, float y){
        _x=x;_y=y;
	}

    static float Dot(const Vector2D& v1, const Vector2D& v2);

	static float Distance(const Vector2D& v1, const Vector2D& v2);

	//given 2 vectors and a point, calculates the point on the line between vectors that is nearest to the point.
	static Vector2D NearestPoint(const Vector2D& v1, const Vector2D& v2, const Vector2D& point);

	//Creators
	static Vector2D Zero();
	static Vector2D Up();
	static Vector2D Down();
	static Vector2D Right();
	static Vector2D Left();

	//Lerp
	static Vector2D Lerp(const Vector2D& v1, const Vector2D& v2, float t);

	//Comparisons

    bool operator!=(const Vector2D& rhs)const ;
    bool operator==(const Vector2D& rhs)const ;

	};

Vector2D operator*(float lhs, const Vector2D& rhs);


} /* namespace SolidUtils */
#endif /* VECTOR2D_H_ */
